package com.woniuxy.commons.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;

@Configuration
public class RedisConfig {

    public RedisTemplate<String ,Object> createRt(RedisConnectionFactory rcf){
        RedisTemplate<String, Object> st = new RedisTemplate<>();
        st.setKeySerializer(RedisSerializer.string());
        st.setValueSerializer(RedisSerializer.json());
        st.setHashKeySerializer(RedisSerializer.string());
        st.setHashValueSerializer(RedisSerializer.string());
        st.setConnectionFactory(rcf);
        st.afterPropertiesSet();
        return st;
    }
}
